import { request } from '../request'

export async function getIndicatorNowValue(timeType: string, indicatorNumber: string) {
  return request.get<{
    indicatorNumber: string
    indicatorName: string
    indicatorCode: string
    val: number | null
    valStr: string | null
    unit: string
  }>(`${SERVICE_ENERGY}/indicator/nowValue/${timeType}/${indicatorNumber}`)
}

// 指标管理
/**
 * 产品对标 isRealTimeIndicator 传 2
 * 数据源配置（能源配置）isRealTimeIndicator 传 2
 * 设备对标 isRealTimeIndicator 不传
 */
/** 查询指标列表 */
export function loadPointList(pointId: number, isVirtually?: 0 | 1, isRealTimeIndicator?: 0 | 1 | 2) {
  return request.get<any[]>(`${SERVICE_ENERGY}/indicator/loadPointList`, {
    params: {
      pointId,
      isVirtually,
      isRealTimeIndicator,
    },
  })
}


export function queryIndicatorsByPage(params: {
  pageNumber: number
  pageSize: number
  containSub?: 0 | 1
  pointId?: number
  keyword?: string
  source?: any
}) {
  return request.post(`${SERVICE_ENERGY}/indicator/page`, params)
}